function Adaptive(){
	$('.task-content').height($(".content").height()-50+'px');
	if(mid !== ""){
		$('.item:first-child').hide();
		$('.aaa').css('margin-top','-20px');
	}
}
$(function(){
	Adaptive();

//未分派的任务
	$.ajax({
			type:"get",
			url:serverIP+"/user/mainTask/list",
			xhrFields:{
		        withCredentials: true    // 设置sessionId相同
		    },
			data: {status:"01"},
			success:function(data){
			  var length=data.data.list.result.length;
			  $("#newNum").text(length);
			  let result = data.data.list.result;
              result.map(function(u){
	        		var str="<div class=\"dat01\">"+"<span class=\"sqdeta\"><img src=\"assets\/img\/bs_03.jpg\">"+ 
					"您有新的任务:打印机:&nbsp;&nbsp;"+"<font color=\"red\" onclick=\"looke(this)\" style=\"cursor: pointer;\">"+ u.taskExplain +"<font style=\"display:none\" class=\"newId\">"+ u.taskId+"<\/font><\/font>&nbsp;&nbsp;&nbsp;&nbsp;没有人员可分派,建议您尽快处理<\/span>"
					+"<p class=\"linkbut\" onclick=\"taskP(this)\"><a href=\"javascript:void(0)\">手动派单<\/a><\/p>"
					+"<\/div>";
	        		$("#newTask").append(str);
             })
        }
	});

//已分派的的任务
	$.ajax({
			type:"get",
			url:serverIP+"/user/mainTask/list",
			xhrFields:{
		        withCredentials: true    // 设置sessionId相同
		    },
		    data: {status:"02",mId:mid},
			success:function(data){
			  var length=data.data.list.result.length;
			  $("#taskingNum").text(length);
			  
			  let result = data.data.list.result;
              result.map(function(u){
	        		var str1="<div class=\"dat01\">"+"<span class=\"sqdeta\"><img src=\"assets\/img\/bs_03.jpg\">"+ 
					"维护任务:&nbsp;&nbsp;"+"<font color=\"red\" onclick=\"look(this)\" style=\"cursor: pointer;\">"+ u.taskExplain +"<font style=\"display:none\" class=\"newId\">"+ u.taskId+"<\/font><\/font>&nbsp;&nbsp;&nbsp;&nbsp;维护人员:<font color=\"green\">"+u.mName+"<\/font><\/span>"
					+"<p class=\"linkbut\" onclick=\"check(this)\"><a href=\"javascript:void(0)\">查看<\/a><\/p>"
					+"<\/div>";
            		$("#nowTask").append(str1);
             })
         }
	});
//	任务列表分页
		var pageSize = 5;
		var currentPage = 1; 
		ajaxTest(currentPage);
		function ajaxTest(currentPage) {
			$.ajax({ 
					type:"post",
					url:serverIP+"/user/mainTask/list",
					xhrFields:{
				        withCredentials: true    // 设置sessionId相同
				    },
					data: {page:currentPage,mId:mid},
					success:function(data){
					  let result = data.data.list.result;
                      var strVar = "";
                      result.map(function(u){
		                if(u.status == "01"){
		                    var status="未开始维护";
		                }else if(u.status == "02"){
		                    var status="正在维护中";
		                }else if(u.status == "03"){
		                    var status="维护完成";
		                }
	                    if(u.grade == "01"){
	                    	var grade="一级";
	                    }else if(u.grade == "02"){
	                    	var grade="二级";
	                    }else if(u.grade == "03"){
	                    	var grade="三级";
	                    }
						
					    strVar += "              <tr>";
					    strVar += "                <td class=\"newId\">"+u.taskId+"<\/td>\n";
					    strVar += "                <td>"+u.taskExplain+"<\/td>\n";
					    strVar += "                <td>"+u.cName+"<\/td>\n";
					    strVar += "                <td>"+u.beginTime+"<\/td>\n";
					    strVar += "                <td>"+u.createTime+"<\/td>\n";
					    strVar += "                <td>"+status+"<\/td>\n";
					    strVar += "                <td>"+grade+"<\/td>\n";
					    strVar += "                <td>"+u.mName+"<\/td>\n";
					    strVar += "                <td>"+u.solution+"<\/td>\n";
					    strVar += "                <td>"+u.remark+"<\/td>\n";
					    strVar += "                <td class=\"check\">"+"<a onclick=\"see(this)\" href=\"javascript:void(0)\">查看<\/a>"+"<\/td>\n";
					    strVar += "              <\/tr>";
					    return strVar;
							
                      });
                      $(".task-tbody").html(strVar);
          		//分页
					$("#page").paging({
						pageNo: data.data.list.curPage,
						totalPage: data.data.list.totalPage,
						totalSize: data.data.list.totalRow,
						callback: function(currentPage) {
							ajaxTest(currentPage); 
						}
					});
				},
				error:function(e){
					console.log(e);
				  }
			});
		};
})			
//点击查看功能
	function look(a){
		 var num=$(a).find(".newId").text();
		 window.location.href="task.html?id="+num;
	}
	function looke(a){
		 var num=$(a).find(".newId").text();
		 window.location.href="Ptask.html?id="+num;
	}
	function check(a){
		 var num=$(a).prev().find(".newId").text();
		 window.location.href="task.html?id="+num;
	}
	function taskP(a){
		 var num=$(a).prev().find(".newId").text();
		 window.location.href="Ptask.html?id="+num;
	}
	function see(a){
		 var num=$(a).parent().parent().find(".newId").text();
		 window.location.href="task.html?id="+num;
	}
//监听浏览器窗口变化
window.onresize = function(){
	var bodyH=$("body").height();
	$(".leftbar").height(bodyH-45+"px");
	$(".content").height(bodyH-45+"px");
	Adaptive();
}